package com.example.flowabledemo.controller;

import com.example.flowabledemo.service.LeaveProcessService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/leave")
@Slf4j
public class IndexController {




    @Autowired
    private LeaveProcessService leaveProcessService;

    /**
     * 启动流程图
     */
    @GetMapping(value = "startLeaveProcess")
    public void startLeaveProcess(String staffId){
        String result = leaveProcessService.startLeaveProcess(staffId);
        log.info(result);
    }

    /**
     * 查看任务
     */
    @GetMapping(value = "queryLeaveProcess")
    public void queryLeaveProcess(String processId){
        String result = leaveProcessService.queryLeaveProcess(processId);
        log.info(result);
    }



    /**
     * 批准
     */
    @GetMapping(value = "applyTask")
    public void applyTask(String taskId){
        String result = leaveProcessService.applyTask(taskId);
        log.info(result);
    }




    /**
     * 驳回
     */
    @GetMapping(value = "rejectTask")
    public void rejectTask(String taskId){
        String result = leaveProcessService.rejectTask(taskId);
        log.info(result);
    }


    /**
     * 生成流程图
     */
    @GetMapping("createProcessDiagramPic")
    public void createProcessDiagramPic(HttpServletResponse httpServletResponse, String processId){

        String result = null;
        try {
            result = leaveProcessService.createProcessDiagramPic(httpServletResponse, processId);
        } catch (Exception e) {
            log.info("异常");
            e.printStackTrace();
        }
        log.info(result);
    }






}
